package studiodiva.portfolio.client.lib.even;

import com.google.gwt.event.shared.GwtEvent.Type;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.event.shared.SimpleEventBus;

public class EventBus {

  private final SimpleEventBus gwtEventBus = new SimpleEventBus();

  public EventBus() {}

  public <Parent, Argument> HandlerRegistration addHandler(Type<EventFunction<Argument>> event,
      EventFunction<Argument> function) {
    return gwtEventBus.addHandler(event, function);
  }

  public <Parent, Argument> void fireEvent(Type<EventFunction<Argument>> event, Argument argument) {
    gwtEventBus.fireEvent(new EventDelegate<Argument>(event, argument));
  }
}
